package com.wy.Listener;

import javax.servlet.*;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
//@WebListener
public class AttributeListener implements ServletRequestAttributeListener, ServletContextAttributeListener, HttpSessionAttributeListener {
    @Override
    public void attributeAdded(ServletContextAttributeEvent event) {
        System.out.println(event.getServletContext() + "添加"+ event.getName() + "=" + event.getValue());

    }

    @Override
    public void attributeRemoved(ServletContextAttributeEvent event) {
        System.out.println(event.getServletContext() + "移除" + event.getName() + "=" + event.getValue());
    }

    @Override
    public void attributeReplaced(ServletContextAttributeEvent event) {
        System.out.println(event.getServletContext() + "替换" + event.getName() + "=" + event.getValue());
    }

    @Override
    public void attributeAdded(ServletRequestAttributeEvent srae) {
        System.out.println(srae.getServletRequest() + "添加"  + srae.getName() + "=" + srae.getValue());
    }

    @Override
    public void attributeRemoved(ServletRequestAttributeEvent srae) {
        System.out.println(srae.getServletRequest() + "移除"+ srae.getName() + "=" + srae.getValue());
    }

    @Override
    public void attributeReplaced(ServletRequestAttributeEvent srae) {
        System.out.println(srae.getServletRequest() + "替换"+ srae.getName() + "=" + srae.getValue());
    }

    @Override
    public void attributeAdded(HttpSessionBindingEvent event) {
        System.out.println(event.getSession() + "添加"+ event.getName() + "=" + event.getValue());
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent event) {
        System.out.println(event.getSession() + "移除"+ event.getName() + "=" + event.getValue());
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent event) {
        System.out.println(event.getSession() + "替换"+ event.getName() + "=" + event.getValue());
    }
}
